import request from '@/utils/request'
import {id} from "element-plus/es/locale/index";

// 查询采购申请列表
export function listApply(query) {
    return request({
        url: '/purchase/apply/list',
        method: 'get',
        params: query
    })
}

// 查询采购申请列表
export function listPurchaseApply(query) {
    return request({
        url: '/purchase/apply/applyList',
        method: 'get',
        params: query
    })
}

// 查询采购申请详细
export function getApply(id) {
    return request({
        url: '/purchase/apply/' + id,
        method: 'get'
    })
}

// 新增采购申请
export function addApply(data) {
    return request({
        url: '/purchase/apply',
        method: 'post',
        data: data
    })
}

// 修改采购申请
export function updateApply(data) {
    return request({
        url: '/purchase/apply',
        method: 'put',
        data: data
    })
}
// 修改状态
export function changeStatus(id,status) {
    const data = {
        id,
        status
    }
    return request({
        url: '/purchase/apply/changeStatus',
        method: 'put',
        data: data
    })
}


// 删除采购申请
export function delApply(id) {
    return request({
        url: '/purchase/apply/' + id,
        method: 'delete'
    })
}

export function deleteByApplyId(purchaseApplyId){
    return request({
        url: '/purchase/material/delPurchaseApplyId/' + purchaseApplyId,
        method: 'delete',
    })
}
// 查询采购申请清单列表
export function listMaterial(query1) {
    return request({
        url: '/purchase/material/list',
        method: 'get',
        params: query1
    })
}
// 获取采购申请编号
export function getCGSQ(){
    return request({
        url: '/purchase/apply/getCGSQ',
        method: 'get'
    })
}
// 查询采购申请清单详细
export function getMaterial(id) {
    return request({
        url: '/purchase/material/' + id,
        method: 'get'
    })
}

export function selectPurchaseApply(id) {
    return request({
        url: '/purchase/material/getSelectPurchaseApply/' + id,
        method: 'get'
    })
}
// 查询申请表最后一个id
export function selectLastId(){
    return request({
        url: '/purchase/apply/lastId',
        method: 'get'
    })
}

// 新增采购申请清单
export function addMaterial(data) {
    return request({
        url: '/purchase/material',
        method: 'post',
        data: data
    })
}

// 修改采购申请清单
export function updateMaterial(data) {
    return request({
        url: '/purchase/material',
        method: 'put',
        data: data
    })
}

// 删除采购申请清单
export function delMaterial(id) {
    return request({
        url: '/purchase/material/' + id,
        method: 'delete'
    })
}
